package frontend.pages.admin.foreignmanager;

import backend.model.admin.ForeignManager;
import backend.service.admin.ForeignManagerService;
import frontend.core.TimeTrackingWebApplication;
import frontend.model.admin.ForeignManagerUIModel;
import frontend.pages.admin.base.AbstractManagingPage;
import org.apache.wicket.markup.html.panel.Panel;
import org.wicketstuff.annotation.mount.MountPath;

import java.util.List;

@MountPath("foreignManager")
public class ForeignManagerManagingPage extends AbstractManagingPage<ForeignManager> {

    public ForeignManagerManagingPage() {
        super("pages.admin.foreignManager.title", "contextualHelp.admin.foreignManager.text");
    }

    @Override
    protected String getAddPanelTitleKey() {
        return "pages.admin.foreignManager.add.title";
    }

    @Override
    protected String getEditPanelTitleKey() {
        return "pages.admin.foreignManager.edit.title";
    }

    @Override
    protected String getNoSelectionMessageKey() {
        return "pages.admin.foreignManager.edit.noSelection";
    }

    @Override
    protected Panel getAddPanel(String panelId) {
        return new ForeignManagerPanel(panelId, getPageParameters(), new ForeignManagerUIModel());
    }

    @Override
    protected Panel getEditPanel(String panelId, ForeignManager dbModel) {
        getPageParameters().clearNamed();
        return new ForeignManagerPanel(panelId, null, new ForeignManagerUIModel(dbModel));
    }

    @Override
    protected List<ForeignManager> loadAvailableEntities() {
        ForeignManagerService foreignManagerService = TimeTrackingWebApplication.getService(ForeignManagerService.class);
        return foreignManagerService.findAllForeignManagers();
    }
}
